import 'package:logging/logging.dart';
import 'package:logging_handlers/server_logging_handlers.dart';

import 'package:loyhd/config.dart';

import 'dart:io';

Logger std = new Logger("Log");

init() {
  var date = new DateTime.now();

  hierarchicalLoggingEnabled = true;

  var logDir = new Directory(LogDir);
  if(!logDir.existsSync()) {
    logDir.createSync(recursive: true);
  }

  Logger.root.level = Level.ALL;
  std.onRecord.listen(
      new SyncFileLoggingHandler(
          './${LogDir}/${date.year}-${date.month}-${date.day}.log'
      )
  );
}
